package com.dominator.utils.sms;

import com.dominFramework.core.typewrap.Dto;
import com.dominator.utils.exception.ApiException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * 验证码工具类
 *
 * @author Administrator
 */
public class SmsUtils {


    private static Logger log = LoggerFactory.getLogger(SmsUtils.class);

    /**
     * 发送短信
     *
     * @param dto
     * @throws ApiException
     */
    public static void sendSms(Dto dto) throws ApiException {
        log.info("--发送短信---");
        switch (dto.getString("stype")) {
            case "1":
                registSms(dto);
                break;
            case "2":
                checkSms(dto);
                break;
            case "3":
                sendNoticeSms(dto);
                break;
        }

    }

    public static void registSms(Dto dto) throws ApiException {
        log.info("--注册短信--");
        MysubmailUtils.sendSms(dto.getString("phoneNum"), dto.getString("verifyCode"));

    }


    /**
     * 发送验证短信
     *
     * @param dto
     * @throws ApiException
     */
    public static void checkSms(Dto dto) throws ApiException {
        log.info("--验证短信--");
        MysubmailUtils.sendSms(dto.getString("phoneNum"), dto.getString("verifyCode"));

    }

    /**
     * 发送通知短信
     *
     * @param dto
     * @throws ApiException
     */
    public static void sendNoticeSms(Dto dto) throws ApiException {
        log.info("--发送通知短信--");
        MysubmailUtils.sendSms(dto.getString("phoneNum"), dto.getString("verifyCode"));

    }

}
